# Definition for singly-linked list.
from typing import Optional


class ListNode:
    def __init__(self, val: int, next: None):
        self.val = val
        self.next: Optional[ListNode] = next